<?php

	function curPageURL()
	{
		$pageURL = 'http';
		
		if ($_SERVER["HTTPS"] == "on")
			$pageURL .= "s";
			
		$pageURL .= "://";
		
		if ($_SERVER["SERVER_PORT"] != "80")
		{
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		}
		else
		{
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		}
		
		return $pageURL;
	}

	function includeDir($dir, $recursive = false)
	{
		$DS = $this->config['DS'];
		
		foreach (glob($dir . $DS . "*.php") as $filename)
		{
			if (!isDir($filename))
			{
				include $filename;
			}
			else
			{
				if ($recursive)
				{
					includeDir($filename, true);
				}
			}
		}
	}
	
	function parse($target, $sep = "::")
	{
		$r = explode($sep, $target);
		
		if ($r[0] == "" or $r[1] == "")
		{
			die("PHP-Puzzle :: Parsing target $target :: Not with format extension" . $sep . "target");
		}
		
		$r['extension'] = $r[0];
		$r['target'] = $r[1];
		
		return $r;
	}
	
	function strstrb($h, $n)
	{
		return array_shift(explode($n,$h,2));
	}
	
?>
